<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>xv6 实验十一 networking | kiloGrand</title><meta name="keywords" content="xv6"><meta name="author" content="kiloGrand"><meta name="copyright" content="kiloGrand"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="https:&#x2F;&#x2F;pdos.csail.mit.edu&#x2F;6.S081&#x2F;2020&#x2F;schedule.html https:&#x2F;&#x2F;pdos.csail.mit.edu&#x2F;6.S081&#x2F;2020&#x2F;labs&#x2F;net.html  实验的目的是为了让我们实现一个网卡驱动在数据链路层的数据收发函数，该函数的实现需要参考E1000的用户手册来完成。 实现 函数e1000_recv需要注意的地方：  不需要加锁，因为该">
<meta property="og:type" content="article">
<meta property="og:title" content="xv6 实验十一 networking">
<meta property="og:url" content="https://kilogrand.gitee.io/2022/09/10/xv6-lab11/index.html">
<meta property="og:site_name" content="kiloGrand">
<meta property="og:description" content="https:&#x2F;&#x2F;pdos.csail.mit.edu&#x2F;6.S081&#x2F;2020&#x2F;schedule.html https:&#x2F;&#x2F;pdos.csail.mit.edu&#x2F;6.S081&#x2F;2020&#x2F;labs&#x2F;net.html  实验的目的是为了让我们实现一个网卡驱动在数据链路层的数据收发函数，该函数的实现需要参考E1000的用户手册来完成。 实现 函数e1000_recv需要注意的地方：  不需要加锁，因为该">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://kilogrand.gitee.io/img/coding.jpg">
<meta property="article:published_time" content="2022-09-10T01:41:10.000Z">
<meta property="article:modified_time" content="2023-03-15T07:20:32.356Z">
<meta property="article:author" content="kiloGrand">
<meta property="article:tag" content="xv6">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://kilogrand.gitee.io/img/coding.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://kilogrand.gitee.io/2022/09/10/xv6-lab11/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'xv6 实验十一 networking',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-03-15 15:20:32'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.2"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/profile.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">46</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">6</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">5</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/img/coding.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">kiloGrand</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> Link</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">xv6 实验十一 networking</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-09-10T01:41:10.000Z" title="发表于 2022-09-10 09:41:10">2022-09-10</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-03-15T07:20:32.356Z" title="更新于 2023-03-15 15:20:32">2023-03-15</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/">操作系统</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.6k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>8分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="xv6 实验十一 networking"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><ul>
<li><a target="_blank" rel="noopener" href="https://pdos.csail.mit.edu/6.S081/2020/schedule.html">https://pdos.csail.mit.edu/6.S081/2020/schedule.html</a></li>
<li><a target="_blank" rel="noopener" href="https://pdos.csail.mit.edu/6.S081/2020/labs/net.html">https://pdos.csail.mit.edu/6.S081/2020/labs/net.html</a></li>
</ul>
<p>实验的目的是为了让我们实现一个网卡驱动在数据链路层的数据收发函数，该函数的实现需要参考E1000的用户手册来完成。</p>
<h2 id="实现"><a href="#实现" class="headerlink" title="实现"></a>实现</h2><ul>
<li><p>函数e1000_recv需要注意的地方：</p>
<ul>
<li>不需要加锁，因为该函数会一次性读取rx_ring上所有的数据，且该函数位于数据链路层，数据链路层还不涉及进程的概念。在读取完数据之后，该函数会调用net_rx函数，将数据送给上层应用。</li>
<li>关于index的理解，在recv函数中，寄存器里保存的index是上次已经被处理过的位置，因此，拿到寄存器里的值后，需要加一移动至下个位置。且本次的数据被送至上层应用之后，会对其mbuf进行清理并申请新的mbuf用于保存下次接收的数据。</li>
</ul>
</li>
</ul>
<ul>
<li><p>函数e1000_transmit需要注意的地方：</p>
<ul>
<li>该相关寄存器中保存的index值为本次需要处理的数据索引，因此，本次处理完之后，需要对该值加一并重新放入寄存器。</li>
</ul>
</li>
</ul>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// kernel/e1000.c</span></span><br><span class="line"><span class="type">int</span></span><br><span class="line"><span class="title function_">e1000_transmit</span><span class="params">(<span class="keyword">struct</span> mbuf *m)</span></span><br><span class="line">&#123;</span><br><span class="line">  <span class="comment">//</span></span><br><span class="line">  <span class="comment">// Your code here.</span></span><br><span class="line">  <span class="comment">//</span></span><br><span class="line">  <span class="comment">// the mbuf contains an ethernet frame; program it into</span></span><br><span class="line">  <span class="comment">// the TX descriptor ring so that the e1000 sends it. Stash</span></span><br><span class="line">  <span class="comment">// a pointer so that it can be freed after sending.</span></span><br><span class="line">  <span class="comment">//</span></span><br><span class="line">  <span class="comment">// printf(&quot;e1000 transmit\n&quot;);</span></span><br><span class="line">  acquire(&amp;e1000_lock);</span><br><span class="line">  <span class="comment">// First ask the E1000 for the TX ring index at which it&#x27;s expecting</span></span><br><span class="line">  <span class="comment">// the next packet, by reading the E1000_TDT control register.</span></span><br><span class="line">  uint32 index = regs[E1000_TDT];</span><br><span class="line">  <span class="comment">// Then check if the the ring is overflowing. If E1000_TXD_STAT_DD is</span></span><br><span class="line">  <span class="comment">// not set in the descriptor indexed by E1000_TDT, the E1000 hasn&#x27;t</span></span><br><span class="line">  <span class="comment">// finished the corresponding previous transmission request, so return an error.</span></span><br><span class="line">  <span class="keyword">if</span> ((tx_ring[index].status &amp; E1000_TXD_STAT_DD) == <span class="number">0</span>) &#123;</span><br><span class="line">    release(&amp;e1000_lock);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">-1</span>;</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// Otherwise, use mbuffree() to free the last mbuf that was transmitted</span></span><br><span class="line">  <span class="comment">// from that descriptor (if there was one).</span></span><br><span class="line">  <span class="keyword">if</span> (tx_mbufs[index]) &#123;</span><br><span class="line">    mbuffree(tx_mbufs[index]);</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// m-&gt;head points to the packet&#x27;s content in memory</span></span><br><span class="line">  tx_ring[index].addr = (uint64)(m-&gt;head);</span><br><span class="line">  <span class="comment">//  and m-&gt;len is the packet length</span></span><br><span class="line">  tx_ring[index].length = m-&gt;len;</span><br><span class="line">  <span class="comment">// Set the necessary cmd flags (look at Section 3.3 in the E1000 manual)</span></span><br><span class="line">  tx_ring[index].cmd = E1000_TXD_CMD_RS | E1000_TXD_CMD_EOP;</span><br><span class="line">  <span class="comment">// and stash away a pointer to the mbuf for later freeing.</span></span><br><span class="line">  tx_mbufs[index] = m;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// update the ring position by adding one to E1000_TDT modulo TX_RING_SIZE.</span></span><br><span class="line">  regs[E1000_TDT] = (index + <span class="number">1</span>) % TX_RING_SIZE;</span><br><span class="line">  release(&amp;e1000_lock);</span><br><span class="line">  <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">static</span> <span class="type">void</span></span><br><span class="line"><span class="title function_">e1000_recv</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line">  <span class="comment">//</span></span><br><span class="line">  <span class="comment">// Your code here.</span></span><br><span class="line">  <span class="comment">//</span></span><br><span class="line">  <span class="comment">// Check for packets that have arrived from the e1000</span></span><br><span class="line">  <span class="comment">// Create and deliver an mbuf for each packet (using net_rx()).</span></span><br><span class="line">  <span class="comment">//</span></span><br><span class="line">  <span class="comment">// printf(&quot;e2000 receive\n&quot;);</span></span><br><span class="line">  <span class="keyword">for</span> (;;) &#123;</span><br><span class="line">    <span class="comment">// First ask the E1000 for the ring index at which the next waiting</span></span><br><span class="line">    <span class="comment">// received packet (if any) is located, by fetching the E1000_RDT</span></span><br><span class="line">    <span class="comment">// control register and adding one modulo RX_RING_SIZE.</span></span><br><span class="line">    uint32 index = regs[E1000_RDT];</span><br><span class="line">    index = (index + <span class="number">1</span>) % RX_RING_SIZE;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// Then check if a new packet is available by checking for the</span></span><br><span class="line">    <span class="comment">// E1000_RXD_STAT_DD bit in the status portion of the descriptor.</span></span><br><span class="line">    <span class="comment">// If not, stop.</span></span><br><span class="line">    <span class="keyword">if</span> ((rx_ring[index].status &amp; E1000_RXD_STAT_DD) == <span class="number">0</span>) &#123;</span><br><span class="line">      <span class="keyword">return</span>;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// update the mbuf&#x27;s m-&gt;len to the length reported in the descriptor.</span></span><br><span class="line">    rx_mbufs[index]-&gt;len = rx_ring[index].length;</span><br><span class="line">    <span class="comment">// rx_mbufs[index]-&gt;head = (char*)rx_ring[index].addr;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// Deliver the mbuf to the network stack using net_rx()</span></span><br><span class="line">    net_rx(rx_mbufs[index]);</span><br><span class="line">    <span class="comment">// Then allocate a new mbuf using mbufalloc() to replace the one just</span></span><br><span class="line">    <span class="comment">// given to net_rx().</span></span><br><span class="line">    <span class="class"><span class="keyword">struct</span> <span class="title">mbuf</span>* <span class="title">buf</span> =</span> mbufalloc(<span class="number">0</span>);</span><br><span class="line">    rx_mbufs[index] = buf;</span><br><span class="line">    <span class="comment">// Program its data pointer (m-&gt;head) into the descriptor.</span></span><br><span class="line">    rx_ring[index].addr = (uint64)buf-&gt;head;</span><br><span class="line">    <span class="comment">// Clear the descriptor&#x27;s status bits to zero</span></span><br><span class="line">    rx_ring[index].status = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// Finally, update the E1000_RDT register to be the index of the</span></span><br><span class="line">    <span class="comment">// last ring descriptor processed.</span></span><br><span class="line">    regs[E1000_RDT] = index;</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>文件nettest.c的dns函数，将8.8.8.8改为114.114.114.114；<br><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// user/nettest.c</span></span><br><span class="line">dst = (<span class="number">114</span> &lt;&lt; <span class="number">24</span>) | (<span class="number">114</span> &lt;&lt; <span class="number">16</span>) | (<span class="number">114</span> &lt;&lt; <span class="number">8</span>) | (<span class="number">114</span> &lt;&lt; <span class="number">0</span>);</span><br></pre></td></tr></table></figure></p>
<h2 id="make-grade"><a href="#make-grade" class="headerlink" title="make grade"></a>make grade</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">grand@Lubuntu ~/xv6-labs-2020 (net)&gt; ./grade-lab-net</span><br><span class="line">make: <span class="string">&#x27;kernel/kernel&#x27;</span> is up to <span class="built_in">date</span>.</span><br><span class="line">== Test running nettests == (4.2s) </span><br><span class="line">== Test   nettest: ping == </span><br><span class="line">  nettest: ping: OK </span><br><span class="line">== Test   nettest: single process == </span><br><span class="line">  nettest: single process: OK </span><br><span class="line">== Test   nettest: multi-process == </span><br><span class="line">  nettest: multi-process: OK </span><br><span class="line">== Test   nettest: DNS == </span><br><span class="line">  nettest: DNS: OK </span><br><span class="line">== Test time == </span><br><span class="line">time: OK </span><br><span class="line">Score: 100/100</span><br></pre></td></tr></table></figure>
<h2 id="git-diff"><a href="#git-diff" class="headerlink" title="git diff"></a>git diff</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br></pre></td><td class="code"><pre><span class="line">diff --git a/kernel/e1000.c b/kernel/e1000.c</span><br><span class="line">index 70a2adf..9260f09 100644</span><br><span class="line">--- a/kernel/e1000.c</span><br><span class="line">+++ b/kernel/e1000.c</span><br><span class="line">@@ -91,7 +91,7 @@ e1000_init(uint32 *xregs)</span><br><span class="line">   regs[E1000_RADV] = 0; // interrupt after every packet (no timer)</span><br><span class="line">   regs[E1000_IMS] = (1 &lt;&lt; <span class="string">7); // RXDW -- Receiver Descriptor Write Back</span></span><br><span class="line"><span class="string"> &#125;</span></span><br><span class="line"><span class="string">-</span></span><br><span class="line"><span class="string">+/*</span></span><br><span class="line"><span class="string"> int</span></span><br><span class="line"><span class="string"> e1000_transmit(struct mbuf *m)</span></span><br><span class="line"><span class="string"> &#123;</span></span><br><span class="line"><span class="string">@@ -116,6 +116,96 @@ e1000_recv(void)</span></span><br><span class="line"><span class="string">   // Create and deliver an mbuf for each packet (using net_rx()).</span></span><br><span class="line"><span class="string">   //</span></span><br><span class="line"><span class="string"> &#125;</span></span><br><span class="line"><span class="string">+*/</span></span><br><span class="line"><span class="string">+</span></span><br><span class="line"><span class="string">+int</span></span><br><span class="line"><span class="string">+e1000_transmit(struct mbuf *m)</span></span><br><span class="line"><span class="string">+&#123;</span></span><br><span class="line"><span class="string">+  //</span></span><br><span class="line"><span class="string">+  // Your code here.</span></span><br><span class="line"><span class="string">+  //</span></span><br><span class="line"><span class="string">+  // the mbuf contains an ethernet frame; program it into</span></span><br><span class="line"><span class="string">+  // the TX descriptor ring so that the e1000 sends it. Stash</span></span><br><span class="line"><span class="string">+  // a pointer so that it can be freed after sending.</span></span><br><span class="line"><span class="string">+  //</span></span><br><span class="line"><span class="string">+  // printf(&quot;e1000 transmit\n&quot;);</span></span><br><span class="line"><span class="string">+  acquire(&amp;e1000_lock);</span></span><br><span class="line"><span class="string">+  // First ask the E1000 for the TX ring index at which it&#x27;s expecting</span></span><br><span class="line"><span class="string">+  // the next packet, by reading the E1000_TDT control register.</span></span><br><span class="line"><span class="string">+  uint32 index = regs[E1000_TDT];</span></span><br><span class="line"><span class="string">+  // Then check if the the ring is overflowing. If E1000_TXD_STAT_DD is</span></span><br><span class="line"><span class="string">+  // not set in the descriptor indexed by E1000_TDT, the E1000 hasn&#x27;t</span></span><br><span class="line"><span class="string">+  // finished the corresponding previous transmission request, so return an error.</span></span><br><span class="line"><span class="string">+  if ((tx_ring[index].status &amp; E1000_TXD_STAT_DD) == 0) &#123;</span></span><br><span class="line"><span class="string">+    release(&amp;e1000_lock);</span></span><br><span class="line"><span class="string">+    return -1;</span></span><br><span class="line"><span class="string">+  &#125;</span></span><br><span class="line"><span class="string">+</span></span><br><span class="line"><span class="string">+  // Otherwise, use mbuffree() to free the last mbuf that was transmitted</span></span><br><span class="line"><span class="string">+  // from that descriptor (if there was one).</span></span><br><span class="line"><span class="string">+  if (tx_mbufs[index]) &#123;</span></span><br><span class="line"><span class="string">+    mbuffree(tx_mbufs[index]);</span></span><br><span class="line"><span class="string">+  &#125;</span></span><br><span class="line"><span class="string">+</span></span><br><span class="line"><span class="string">+  // m-&gt;head points to the packet&#x27;s content in memory</span></span><br><span class="line"><span class="string">+  tx_ring[index].addr = (uint64)(m-&gt;head);</span></span><br><span class="line"><span class="string">+  //  and m-&gt;len is the packet length</span></span><br><span class="line"><span class="string">+  tx_ring[index].length = m-&gt;len;</span></span><br><span class="line"><span class="string">+  // Set the necessary cmd flags (look at Section 3.3 in the E1000 manual)</span></span><br><span class="line"><span class="string">+  tx_ring[index].cmd = E1000_TXD_CMD_RS | E1000_TXD_CMD_EOP;</span></span><br><span class="line"><span class="string">+  // and stash away a pointer to the mbuf for later freeing.</span></span><br><span class="line"><span class="string">+  tx_mbufs[index] = m;</span></span><br><span class="line"><span class="string">+</span></span><br><span class="line"><span class="string">+  // update the ring position by adding one to E1000_TDT modulo TX_RING_SIZE.</span></span><br><span class="line"><span class="string">+  regs[E1000_TDT] = (index + 1) % TX_RING_SIZE;</span></span><br><span class="line"><span class="string">+  release(&amp;e1000_lock);</span></span><br><span class="line"><span class="string">+  return 0;</span></span><br><span class="line"><span class="string">+&#125;</span></span><br><span class="line"><span class="string">+</span></span><br><span class="line"><span class="string">+static void</span></span><br><span class="line"><span class="string">+e1000_recv(void)</span></span><br><span class="line"><span class="string">+&#123;</span></span><br><span class="line"><span class="string">+  //</span></span><br><span class="line"><span class="string">+  // Your code here.</span></span><br><span class="line"><span class="string">+  //</span></span><br><span class="line"><span class="string">+  // Check for packets that have arrived from the e1000</span></span><br><span class="line"><span class="string">+  // Create and deliver an mbuf for each packet (using net_rx()).</span></span><br><span class="line"><span class="string">+  //</span></span><br><span class="line"><span class="string">+  // printf(&quot;e2000 receive\n&quot;);</span></span><br><span class="line"><span class="string">+  for (;;) &#123;</span></span><br><span class="line"><span class="string">+    // First ask the E1000 for the ring index at which the next waiting</span></span><br><span class="line"><span class="string">+    // received packet (if any) is located, by fetching the E1000_RDT</span></span><br><span class="line"><span class="string">+    // control register and adding one modulo RX_RING_SIZE.</span></span><br><span class="line"><span class="string">+    uint32 index = regs[E1000_RDT];</span></span><br><span class="line"><span class="string">+    index = (index + 1) % RX_RING_SIZE;</span></span><br><span class="line"><span class="string">+</span></span><br><span class="line"><span class="string">+    // Then check if a new packet is available by checking for the</span></span><br><span class="line"><span class="string">+    // E1000_RXD_STAT_DD bit in the status portion of the descriptor.</span></span><br><span class="line"><span class="string">+    // If not, stop.</span></span><br><span class="line"><span class="string">+    if ((rx_ring[index].status &amp; E1000_RXD_STAT_DD) == 0) &#123;</span></span><br><span class="line"><span class="string">+      return;</span></span><br><span class="line"><span class="string">+    &#125;</span></span><br><span class="line"><span class="string">+</span></span><br><span class="line"><span class="string">+    // update the mbuf&#x27;s m-&gt;len to the length reported in the descriptor.</span></span><br><span class="line"><span class="string">+    rx_mbufs[index]-&gt;len = rx_ring[index].length;</span></span><br><span class="line"><span class="string">+    // rx_mbufs[index]-&gt;head = (char*)rx_ring[index].addr;</span></span><br><span class="line"><span class="string">+</span></span><br><span class="line"><span class="string">+    // Deliver the mbuf to the network stack using net_rx()</span></span><br><span class="line"><span class="string">+    net_rx(rx_mbufs[index]);</span></span><br><span class="line"><span class="string">+    // Then allocate a new mbuf using mbufalloc() to replace the one just</span></span><br><span class="line"><span class="string">+    // given to net_rx().</span></span><br><span class="line"><span class="string">+    struct mbuf* buf = mbufalloc(0);</span></span><br><span class="line"><span class="string">+    rx_mbufs[index] = buf;</span></span><br><span class="line"><span class="string">+    // Program its data pointer (m-&gt;head) into the descriptor.</span></span><br><span class="line"><span class="string">+    rx_ring[index].addr = (uint64)buf-&gt;head;</span></span><br><span class="line"><span class="string">+    // Clear the descriptor&#x27;s status bits to zero</span></span><br><span class="line"><span class="string">+    rx_ring[index].status = 0;</span></span><br><span class="line"><span class="string">+</span></span><br><span class="line"><span class="string">+    // Finally, update the E1000_RDT register to be the index of the</span></span><br><span class="line"><span class="string">+    // last ring descriptor processed.</span></span><br><span class="line"><span class="string">+    regs[E1000_RDT] = index;</span></span><br><span class="line"><span class="string">+  &#125;</span></span><br><span class="line"><span class="string">+&#125;</span></span><br><span class="line"><span class="string"> </span></span><br><span class="line"><span class="string"> void</span></span><br><span class="line"><span class="string"> e1000_intr(void)</span></span><br><span class="line"><span class="string">diff --git a/packets.pcap b/packets.pcap</span></span><br><span class="line"><span class="string">index 82d353e..505fd0d 100644</span></span><br><span class="line"><span class="string">Binary files a/packets.pcap and b/packets.pcap differ</span></span><br><span class="line"><span class="string">diff --git a/time.txt b/time.txt</span></span><br><span class="line"><span class="string">new file mode 100644</span></span><br><span class="line"><span class="string">index 0000000..f599e28</span></span><br><span class="line"><span class="string">--- /dev/null</span></span><br><span class="line"><span class="string">+++ b/time.txt</span></span><br><span class="line"><span class="string">@@ -0,0 +1 @@</span></span><br><span class="line"><span class="string">+10</span></span><br><span class="line"><span class="string">diff --git a/user/nettests.c b/user/nettests.c</span></span><br><span class="line"><span class="string">index edf46ef..6f297b3 100644</span></span><br><span class="line"><span class="string">--- a/user/nettests.c</span></span><br><span class="line"><span class="string">+++ b/user/nettests.c</span></span><br><span class="line"><span class="string">@@ -198,7</span> +198,9 @@ dns()</span><br><span class="line">   memset(ibuf, 0, N);</span><br><span class="line">   </span><br><span class="line">   // 8.8.8.8: google<span class="string">&#x27;s name server</span></span><br><span class="line"><span class="string">-  dst = (8 &lt;&lt; 24) | (8 &lt;&lt; 16) | (8 &lt;&lt; 8) | (8 &lt;&lt; 0);</span></span><br><span class="line"><span class="string">+  // dst = (8 &lt;&lt; 24) | (8 &lt;&lt; 16) | (8 &lt;&lt; 8) | (8 &lt;&lt; 0);</span></span><br><span class="line"><span class="string">+  // 114.114.114.114: 电信联通移动全国通用DNS</span></span><br><span class="line"><span class="string">+  dst = (114 &lt;&lt; 24) | (114 &lt;&lt; 16) | (114 &lt;&lt; 8) | (114 &lt;&lt; 0);</span></span><br><span class="line"><span class="string"> </span></span><br><span class="line"><span class="string">   if((fd = connect(dst, 10000, 53)) &lt; 0)&#123;</span></span><br><span class="line"><span class="string">     fprintf(2, &quot;ping: connect() failed\n&quot;);</span></span><br></pre></td></tr></table></figure></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://kilogrand.gitee.io">kiloGrand</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://kilogrand.gitee.io/2022/09/10/xv6-lab11/">https://kilogrand.gitee.io/2022/09/10/xv6-lab11/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://kilogrand.gitee.io" target="_blank">kiloGrand</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/xv6/">xv6</a></div><div class="post_share"></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2022/09/09/xv6-lab10/"><img class="prev-cover" src="/img/coding.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">xv6 实验十 mmap</div></div></a></div><div class="next-post pull-right"><a href="/2022/09/11/xv6-questions/"><img class="next-cover" src="/img/coding.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">xv6问题集合</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2022/08/31/xv6-Chapter-0/" title="xv6 riscv book 中文版声明"><img class="cover" src="/img/coding.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-08-31</div><div class="title">xv6 riscv book 中文版声明</div></div></a></div><div><a href="/2022/08/31/xv6-Chapter-1/" title="xv6 第一章"><img class="cover" src="/img/coding.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-08-31</div><div class="title">xv6 第一章</div></div></a></div><div><a href="/2022/08/31/xv6-Chapter-2/" title="xv6 第二章"><img class="cover" src="/img/coding.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-08-31</div><div class="title">xv6 第二章</div></div></a></div><div><a href="/2022/08/31/xv6-Chapter-3/" title="xv6 第三章"><img class="cover" src="/img/coding.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-08-31</div><div class="title">xv6 第三章</div></div></a></div><div><a href="/2022/08/31/xv6-Chapter-4/" title="xv6 第四章"><img class="cover" src="/img/coding.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-08-31</div><div class="title">xv6 第四章</div></div></a></div><div><a href="/2022/08/31/xv6-Chapter-5/" title="xv6 第五章"><img class="cover" src="/img/coding.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-08-31</div><div class="title">xv6 第五章</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/profile.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">kiloGrand</div><div class="author-info__description">coder && data-science researcher</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">46</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">6</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">5</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/kiloGrand/"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0"><span class="toc-number">1.</span> <span class="toc-text">实现</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#make-grade"><span class="toc-number">2.</span> <span class="toc-text">make grade</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#git-diff"><span class="toc-number">3.</span> <span class="toc-text">git diff</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/03/24/kuiper_infer-L14/" title="自制深度学习框架--实现Yolov5的推理">自制深度学习框架--实现Yolov5的推理</a><time datetime="2023-03-24T12:00:00.000Z" title="发表于 2023-03-24 20:00:00">2023-03-24</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/03/23/kuiper_infer-L13/" title="自制深度学习框架--实现ResNet网络的推理">自制深度学习框架--实现ResNet网络的推理</a><time datetime="2023-03-23T12:00:00.000Z" title="发表于 2023-03-23 20:00:00">2023-03-23</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/03/22/kuiper_infer-L12/" title="自制深度学习框架--算子的执行流程">自制深度学习框架--算子的执行流程</a><time datetime="2023-03-22T12:00:00.000Z" title="发表于 2023-03-22 20:00:00">2023-03-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/03/21/kuiper_infer-L11/" title="自制深度学习框架--再探Tensor类并构建计算图的图关系">自制深度学习框架--再探Tensor类并构建计算图的图关系</a><time datetime="2023-03-21T12:00:00.000Z" title="发表于 2023-03-21 20:00:00">2023-03-21</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/03/20/kuiper_infer-L10/" title="自制深度学习框架--Im2Col原理与卷积层的实现">自制深度学习框架--Im2Col原理与卷积层的实现</a><time datetime="2023-03-20T12:00:00.000Z" title="发表于 2023-03-20 20:00:00">2023-03-20</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2022 - 2023 By kiloGrand</div><div class="footer_custom_text">Hi, welcome to my blog!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>if (!window.MathJax) {
  window.MathJax = {
    tex: {
      inlineMath: [ ['$','$'], ["\\(","\\)"]],
      tags: 'ams'
    },
    chtml: {
      scale: 1.2
    },
    options: {
      renderActions: {
        findScript: [10, doc => {
          for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
            const display = !!node.type.match(/; *mode=display/)
            const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
            const text = document.createTextNode('')
            node.parentNode.replaceChild(text, node)
            math.start = {node: text, delim: '', n: 0}
            math.end = {node: text, delim: '', n: 0}
            doc.math.push(math)
          }
        }, ''],
        insertScript: [200, () => {
          document.querySelectorAll('mjx-container:not\([display]\)').forEach(node => {
            const target = node.parentNode
            if (target.nodeName.toLowerCase() === 'li') {
              target.parentNode.classList.add('has-jax')
            } else {
              target.classList.add('has-jax')
            }
          });
        }, '', false]
      }
    }
  }
  
  const script = document.createElement('script')
  script.src = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'
  script.id = 'MathJax-script'
  script.async = true
  document.head.appendChild(script)
} else {
  MathJax.startup.document.state(0)
  MathJax.texReset()
  MathJax.typeset()
}</script></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>